<!-- Copyright 2017 Capital One Services, LLC and Bitwise, Inc.
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License. -->
 
<!doctype html>
<html>
<head>
	<title>MetaPivot</title>
	<link rel="stylesheet" type="text/css" href="../../css/style.css">
</head>
<body>
<p><span class="header-1">MetaPivot</span></p>
<p><span>The meta pivot function splits the input records by field(s) in input to create multiple records on the out port. It is a special type of pivot function which transforms columns to rows. The output of meta pivot function always contains 2 fields. The first field contains the name of the column passed as input to meta pivot. The second field contains the value of that column.</span></p>
<p><span>This function requires following inputs:</span></p>
<ul>
	<li><span><b>Input fields</b>: The fields to split the input on. These are passed to the meta pivot function using <a href="../../Components/transform/Normalize_Operation_Editor.html#input_fields_grid">input fields grid</a> on normalize operation editor window.</span></li>
	<li><span><b>Output fields</b>: The fields present on the output. There should always be just 2 fields in the output for the meta pivot function. These are passed to the meta pivot function using <a href="../../Components/transform/Normalize_Operation_Editor.html#output_fields_grid">output fields grid</a> on normalize operation editor window. The first field contains the name of the column passed as input to meta pivot. The second field contains the value of that column.</span></li>
</ul>
<p><span class="header-2">Example</span></p>
<p><span class="header-3">Input file</span></p>
<p><span>
	<table>
		<tr>
			<th style="width:50px;">id</th>
			<th style="width:80px;">name</th>
			<th style="width:80px;">English</th>
			<th style="width:80px;">French</th>
			<th style="width:80px;">Geography</th>
			<th style="width:80px;">History</th>
			<th style="width:80px;">Maths</th>
		</tr>
		<tr>
			<td>1</td>
			<td>John</td>
			<td>80</td>
			<td>75</td>
			<td>84</td>
			<td>43</td>
			<td>58</td>
		</tr>
		<tr>
			<td>2</td>
			<td>Mary</td>
			<td>65</td>
			<td>35</td>
			<td>98</td>
			<td>65</td>
			<td>69</td>
		</tr>
	</table>
</span></p>
<p><span class="header-3">Input fields to meta pivot</span></p>
<ul>
	<li><span>English</span></li>
	<li><span>French</span></li>
	<li><span>Geography</span></li>
	<li><span>History</span></li>
	<li><span>Maths</span></li>
</ul>
<p><span class="header-3">Output fields for meta pivot</span></p>
<ul>
	<li><span>Subject</span></li>
	<li><span>Marks</span></li>
</ul>
<p><span class="header-3">Pass-through fields</span></p>
<ul>
	<li><span>id</span></li>
	<li><span>name</span></li>
</ul>
<p><span class="header-3">Output of meta pivot function</span></p>
<p><span>
	<table>
		<tr>
			<th style="width:50px;">id</th>
			<th style="width:80px;">name</th>
			<th style="width:80px;">Subject</th>
			<th style="width:80px;">Marks</th>
		</tr>
		<tr>
			<td>1</td>
			<td>John</td>
			<td>English</td>
			<td>80</td>
		</tr>
		<tr>
			<td>1</td>
			<td>John</td>
			<td>French</td>
			<td>75</td>
		</tr>
		<tr>
			<td>1</td>
			<td>John</td>
			<td>Geography</td>
			<td>84</td>
		</tr>
		<tr>
			<td>1</td>
			<td>John</td>
			<td>History</td>
			<td>43</td>
		</tr>
		<tr>
			<td>1</td>
			<td>John</td>
			<td>Maths</td>
			<td>58</td>
		</tr>
		<tr>
			<td>2</td>
			<td>Mary</td>
			<td>English</td>
			<td>65</td>
		</tr>
		<tr>
			<td>2</td>
			<td>Mary</td>
			<td>French</td>
			<td>35</td>
		</tr>
		<tr>
			<td>2</td>
			<td>Mary</td>
			<td>Geography</td>
			<td>98</td>
		</tr>
		<tr>
			<td>2</td>
			<td>Mary</td>
			<td>History</td>
			<td>65</td>
		</tr>
		<tr>
			<td>2</td>
			<td>Mary</td>
			<td>Maths</td>
			<td>69</td>
		</tr>
	</table>
</span></p>
</body>
</html>